package util;

import android.content.Context;
import android.content.SharedPreferences;

public class SaveUser {

    // 保存QQ账号和登录密码到data.xml文件中
    public static boolean saveUserInfo(Context context, String name, String password) {
        SharedPreferences sp = context.getSharedPreferences(name, Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();
        edit.putString("pwd", password);
        edit.apply();
        return true;
    }

    //从data.xml文件中获取存储的QQ帐号和密码
    public static String getUserInfo(Context context, String name) {
        SharedPreferences sp = context.getSharedPreferences(name, Context.MODE_PRIVATE);
        return sp.getString("pwd", null);
    }
}
